{{/* Get the filepath */}}
{{/* If the first character is "/", the path is from the site's `baseURL`. */}}
{{ if eq (.Get "src" | printf "%.1s") "/" }}

{{/* Use Hugo `readfile` behavior of path from site's `baseURL`. */}}
{{ $.Scratch.Set "filepath" ( .Get "src" ) }}

{{ else }}

{{/* Make relative: Fetch the current directory and then append it to the specified `file=""` value */}}
{{ $.Scratch.Set "filepath" $.Page.Dir }}
{{ $.Scratch.Add "filepath" ( .Get "src" ) }}

{{ end }}



<div class="diagram">

<span class="diagram-title">{{ .Get "title" }}</span>

{{/* Check if the specified file exists */}}
{{ if fileExists ($.Scratch.Get "filepath") }}

(<a href="{{ $.Scratch.Get "filepath" }}" target="_blank">open in new tab</a>)
<br />
<img src="{{ $.Scratch.Get "filepath" }}" />

{{/* Say something if the file is not found and display the path that was specified in the shortcode (`file=" "`). */}}
{{ else }}

<br />
<p style="color: #D74848"><b><i>Something's not right. The <code>{{ .Get "src" }}</code> file was not found.</i></b></p>

{{ end }}

</div>
